﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace KinectedMusic.Audio
{
    public class AudioControl : IAudioControl
    {
        SongControl songControl;
        Song song;

        public AudioControl()
        {
            song = new Song();
            song.BeatsPerMinute = 140.0;
            song.BeatsPerBar = 4;

            songControl = new SongControl(song);
        }

        public IInstrument AddInstrument(string pluginName)
        {
            IInstrument instrument = song.AddInstrument(pluginName, songControl.BufferSize);
            return instrument;
        }

        public List<IInstrument> getInstruments()
        {
            return song.getInstruments();
        }

        public void Start()
        {
            Thread.CurrentThread.Priority = ThreadPriority.Highest;
            songControl.StartSong();
        }

        public void Stop()
        {
            songControl.StopSong();
        }

        public void StartSong()
        {
            Start();
        }

        public void StopSong()
        {
            Stop();
        }

        public void ResetSong()
        {
            //TODO: need to put in Ist to delete all
            throw new NotImplementedException();
        }
    }
}
